﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_DSJCJ.BLL
{
    /// <summary>
    /// 广告逻辑类
    /// </summary>
    public class Ad
    {
        /// <summary>
        /// 广告数据类
        /// </summary>
        public DAL.Ad adDAL = new DAL.Ad();
        public Ad()
        {
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_DSJCJ.Model.Ad> GetModelList(string strWhere)
        {
            DataSet ds = adDAL.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_DSJCJ.Model.Ad> GetModelList(int top, string strWhere, string filedOrder)
        {
            DataSet ds = adDAL.GetList(top, strWhere, filedOrder);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_DSJCJ.Model.Ad> DataTableToList(DataTable dt)
        {
            List<ElingOA6_DSJCJ.Model.Ad> modelList = new List<ElingOA6_DSJCJ.Model.Ad>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_DSJCJ.Model.Ad model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = adDAL.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
